package com.wjk.kylin.rpc.core.config;

import com.wjk.kylin.rpc.core.registry.RegistryTypeEnum;
import com.wjk.kylin.rpc.core.serialize.Serializer;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author wjk
 */
@ConfigurationProperties(prefix = "kylin.rpc.provider")
public class RpcProviderConfigProperties {
    /**
     * 是否启动rpc 服务提供者，默认不启用
     */
    private boolean enable = false;
    /**
     * 序列化：默认hessian
     */
    private Serializer.Algorithm serializer = Serializer.Algorithm.Hessian;
    /**
     * 服务提供者和服务消费者token验证，默认不使用
     */
    private String accessToken;
    /**
     * 注册中心，默认地址127.0.0.1：2181
     *         默认使用zookeeper
     */
    private Registry registry = new Registry();
    /**
     * 处理服务消费者业务的线程池核心线程数，默认66
     */
    private int corePoolSize = 66;
    /**
     * 处理服务消费者业务的线程池最大线程数，默认66
     */
    private int maxPoolSize = 66;
    /**
     * 对外提供ip地址，默认服务提供者启动服务地址id
     */
    private String ip;
    /**
     * 对外提供端口，默认9527
     */
    private int port = 9527;

    public int getCorePoolSize() {
        return corePoolSize;
    }

    public void setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    public int getMaxPoolSize() {
        return maxPoolSize;
    }

    public void setMaxPoolSize(int maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Serializer.Algorithm getSerializer() {
        return serializer;
    }

    public void setSerializer(Serializer.Algorithm serializer) {
        this.serializer = serializer;
    }

    public Registry getRegistry() {
        return registry;
    }

    public void setRegistry(Registry registry) {
        this.registry = registry;
    }

    public static class Registry {
        private String address = "127.0.0.1:2181";
        private RegistryTypeEnum type = RegistryTypeEnum.ZOOKEEPER;

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public RegistryTypeEnum getType() {
            return type;
        }

        public void setType(RegistryTypeEnum type) {
            this.type = type;
        }
    }


}
